package com.aaa.sbms.controller;

import com.aaa.sbms.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("group")
public class GroupController {

    @Autowired(required = false)
    private GroupService groupService;

    /**
     * 查询部门
     * @return
     */
    @RequestMapping("depts")
    public Map depts(){
        return groupService.depts();
    }

    /**
     * 查询领导人
     * @return
     */
    @RequestMapping("users")
    public Map users(){
        return groupService.users();
    }

    /**
     * 分页查询班组
     * @param map
     * @return
     */
    @RequestMapping("page")
    public Map page(@RequestParam Map map){
        return groupService.page(map);
    }

    /**
     * 查询一个班组
     * @param groupid
     * @return
     */
    @RequestMapping("groupOne")
    public Map groupOne(Integer groupid){
        return groupService.groupOne(groupid);
    }

    /**
     * 添加
     * @param map
     * @return
     */
    @RequestMapping("add")
    public int add(@RequestBody Map map){
        return groupService.add(map);
    }

    /**
     * 修改
     * @param map
     * @return
     */
    @RequestMapping("update")
    public int update(@RequestBody Map map){
        return groupService.update(map);
    }

    /**
     * 删除
     * @param groupid
     * @return
     */
    @RequestMapping("delete")
    public int delete(Integer groupid){
        return groupService.delete(groupid);
    }
}
